package com.wangsh.userscenter.users.pojo;

import java.util.Date;

import com.wangsh.userscenter.common.pojo.BasePojo;
import com.wangsh.userscenter.common.util.ConstatFinalUtil;
import com.wangsh.userscenter.system.pojo.ARegion;

/**
 * 用户的POJO类
 * @author wangsh
 *
 */
public class AUsers extends BasePojo<AUsers>
{
	private int id;
	private int regionId;
	private String email ; 
	private String password ;
	private String nickName ;
	private String trueName ; 
	private String qq ; 
	private String phone ; 
	private int loginCount ; 
	private int failedCount ;
	private Date failedTime ; 
	private String address ; 
	private String photoPath ; 
	private byte emailStatus ; 
	private byte phoneStatus ; 
	private byte idcardStatus ; 
	private byte sex ; 
	private byte status ; 
	private Date createTime;
	private Date updateTime;
	private Date lastLoginTime ; 
	
	//字符串表示
	private String tokentStr ;
	private String statusStr ; 
	private String emailStatusStr ;
	private String phoneStatusStr ; 
	private String sexStr ; 
	
	/* 对象表示 */
	private AUsersExtend usersExtend ; 
	private ARegion region ; 

	public int getId()
	{
		return id;
	}

	public int getRegionId()
	{
		return regionId;
	}

	public void setRegionId(int regionId)
	{
		this.regionId = regionId;
	}

	public String getEmail()
	{
		return email;
	}

	public void setEmail(String email)
	{
		this.email = email;
	}

	public String getPassword()
	{
		return password;
	}

	public void setPassword(String password)
	{
		this.password = password;
	}

	public String getNickName()
	{
		return nickName;
	}

	public void setNickName(String nickName)
	{
		this.nickName = nickName;
	}

	public String getQq()
	{
		return qq;
	}

	public void setQq(String qq)
	{
		this.qq = qq;
	}

	public String getPhone()
	{
		return phone;
	}

	public void setPhone(String phone)
	{
		this.phone = phone;
	}

	public int getLoginCount()
	{
		return loginCount;
	}

	public void setLoginCount(int loginCount)
	{
		this.loginCount = loginCount;
	}

	public int getFailedCount()
	{
		return failedCount;
	}

	public void setFailedCount(int failedCount)
	{
		this.failedCount = failedCount;
	}

	public String getAddress()
	{
		return address;
	}

	public void setAddress(String address)
	{
		this.address = address;
	}

	public String getPhotoPath()
	{
		return photoPath;
	}
	
	public String getPhotoPathWebsite()
	{
		return ConstatFinalUtil.CONFIG_JSON.getString("website.fileUrl") + photoPath;
	}

	public void setPhotoPath(String photoPath)
	{
		this.photoPath = photoPath;
	}

	public byte getEmailStatus()
	{
		return emailStatus;
	}

	public void setEmailStatus(byte emailStatus)
	{
		this.emailStatus = emailStatus;
	}

	public byte getPhoneStatus()
	{
		return phoneStatus;
	}

	public void setPhoneStatus(byte phoneStatus)
	{
		this.phoneStatus = phoneStatus;
	}

	public byte getIdcardStatus()
	{
		return idcardStatus;
	}

	public void setIdcardStatus(byte idcardStatus)
	{
		this.idcardStatus = idcardStatus;
	}

	public byte getStatus()
	{
		return status;
	}

	public void setStatus(byte status)
	{
		this.status = status;
	}

	public Date getCreateTime()
	{
		return createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public Date getUpdateTime()
	{
		return updateTime;
	}

	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	public Date getLastLoginTime()
	{
		return lastLoginTime;
	}

	public void setLastLoginTime(Date lastLoginTime)
	{
		this.lastLoginTime = lastLoginTime;
	}

	public String getTokenStr()
	{
		return tokentStr;
	}

	public void setTokenStr(String tokentStr)
	{
		this.tokentStr = tokentStr;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public String getStatusStr()
	{
		// 根据状态值获取字符串描述
		AUsersEnum[] usersEnums = AUsersEnum.values();
		for (int i = 0; i < usersEnums.length; i++)
		{
			AUsersEnum usersEnum = usersEnums[i];
			if (usersEnum.toString().startsWith("STATUS_"))
			{
				// 表示是状态的标识
				if (usersEnum.getStatus() == this.getStatus())
				{
					this.statusStr = usersEnum.getName();
					break;
				}
			}
		}
		return statusStr;
	}

	public AUsersExtend getUsersExtend()
	{
		return usersExtend;
	}

	public void setUsersExtend(AUsersExtend usersExtend)
	{
		this.usersExtend = usersExtend;
	}

	@Override
	public String toString()
	{
		return "AUsers [id=" + id + ", regionId=" + regionId + ", email=" + email
				+ ", password=" + password + ", nickName=" + nickName + ", qq=" + qq + ", phone=" + phone
				+ ", loginCount=" + loginCount + ", address=" + address
				+ ", photoImg=" + photoPath + ", emailStatus=" + emailStatus + ", phoneStatus=" + phoneStatus
				+ ", idcardStatus=" + idcardStatus + ", status=" + status + ", createTime=" + createTime
				+ ", updateTime=" + updateTime + ", lastLoginTime=" + lastLoginTime + ", tokentStr=" + tokentStr
				+ ", statusStr=" + statusStr + ", usersExtend=" + usersExtend + "]";
	}

	public String getEmailStatusStr()
	{
		// 根据状态值获取字符串描述
		AUsersEnum[] usersEnums = AUsersEnum.values();
		for (int i = 0; i < usersEnums.length; i++)
		{
			AUsersEnum usersEnum = usersEnums[i];
			if (usersEnum.toString().startsWith("EMAILSTATUS_"))
			{
				// 表示是状态的标识
				if (usersEnum.getStatus() == this.getEmailStatus())
				{
					this.emailStatusStr = usersEnum.getName();
					break;
				}
			}
		}
		return emailStatusStr;
	}

	public ARegion getRegion()
	{
		return region;
	}

	public void setRegion(ARegion region)
	{
		this.region = region;
	}

	public String getPhoneStatusStr()
	{
		// 根据状态值获取字符串描述
		AUsersEnum[] usersEnums = AUsersEnum.values();
		for (int i = 0; i < usersEnums.length; i++)
		{
			AUsersEnum usersEnum = usersEnums[i];
			if (usersEnum.toString().startsWith("PHONE_STATUS_"))
			{
				// 表示是状态的标识
				if (usersEnum.getStatus() == this.getPhoneStatus())
				{
					this.phoneStatusStr = usersEnum.getName();
					break;
				}
			}
		}
		return phoneStatusStr;
	}
	
	public String getSexStr()
	{
		/*
		 * 循环枚举
		 */
		AAdminsEnum[] adminsEnums = AAdminsEnum.values();
		for (int i = 0; i < adminsEnums.length; i++)
		{
			AAdminsEnum adminsEnum = adminsEnums[i];
			/* 一个表中有多个byte类型的字段(枚举)
			 * 不同的byte字段可以有相同的值,
			 * 所以在判断的时候,即要判断值,又要判断名称
			 *  */
			if(this.getSex() == adminsEnum.getStatus() && adminsEnum.toString().startsWith("SEX"))
			{
				this.sexStr = adminsEnum.getInfo() ; 
			}
			/*ConstatFinalUtil.SYS_LOGGER.info("info:{},status:{},属性名:{}",
					adminsEnum.getInfo(),adminsEnum.getStatus(),adminsEnum);*/
		}
		return sexStr;
	}

	public byte getSex()
	{
		return sex;
	}

	public void setSex(byte sex)
	{
		this.sex = sex;
	}

	public Date getFailedTime()
	{
		return failedTime;
	}

	public void setFailedTime(Date failedTime)
	{
		this.failedTime = failedTime;
	}

	public String getTrueName()
	{
		return trueName;
	}

	public void setTrueName(String trueName)
	{
		this.trueName = trueName;
	}
}